package com.weijin.bookborrowmanagesystem.controller;

import com.weijin.bookborrowmanagesystem.common.Result;
import com.weijin.bookborrowmanagesystem.pojo.Book;
import com.weijin.bookborrowmanagesystem.service.BookService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author WeiJin
 * @Version 1.0
 * @Date 2025/3/13 10:18
 */
@RestController
@RequestMapping("/books")
@Api(tags = "图书控制层类")
public class BookController {
    @Resource
    private BookService bookService;

    @PostMapping("/add")
    @ApiOperation("添加图书")
    public Result<String> addBook(@RequestBody Book book){
        return bookService.addBook(book);
    }

    @GetMapping("/query")
    @ApiOperation("获取所有图书")
    public Result<List<Book>> queryAll(){
        return bookService.queryAll();
    }
}
